{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c5ca4dc2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from pandas import Series, DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f68d8ed5",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>CompTotal</th>\n",
       "      <th>LanguageHaveWorkedWith</th>\n",
       "      <th>LanguageWantToWorkWith</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Slovakia</td>\n",
       "      <td>4800.0</td>\n",
       "      <td>C++;HTML/CSS;JavaScript;Objective-C;PHP;Swift</td>\n",
       "      <td>Swift</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Netherlands</td>\n",
       "      <td>NaN</td>\n",
       "      <td>JavaScript;Python</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Russian Federation</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Assembly;C;Python;R;Rust</td>\n",
       "      <td>Julia;Python;Rust</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Austria</td>\n",
       "      <td>NaN</td>\n",
       "      <td>JavaScript;TypeScript</td>\n",
       "      <td>JavaScript;TypeScript</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>United Kingdom of Great Britain and Northern I...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Bash/Shell;HTML/CSS;Python;SQL</td>\n",
       "      <td>Bash/Shell;HTML/CSS;Python;SQL</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                             Country  CompTotal  \\\n",
       "0                                           Slovakia     4800.0   \n",
       "1                                        Netherlands        NaN   \n",
       "2                                 Russian Federation        NaN   \n",
       "3                                            Austria        NaN   \n",
       "4  United Kingdom of Great Britain and Northern I...        NaN   \n",
       "\n",
       "                          LanguageHaveWorkedWith  \\\n",
       "0  C++;HTML/CSS;JavaScript;Objective-C;PHP;Swift   \n",
       "1                              JavaScript;Python   \n",
       "2                       Assembly;C;Python;R;Rust   \n",
       "3                          JavaScript;TypeScript   \n",
       "4                 Bash/Shell;HTML/CSS;Python;SQL   \n",
       "\n",
       "           LanguageWantToWorkWith  \n",
       "0                           Swift  \n",
       "1                             NaN  \n",
       "2               Julia;Python;Rust  \n",
       "3           JavaScript;TypeScript  \n",
       "4  Bash/Shell;HTML/CSS;Python;SQL  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Open the file `so_2021_survey_results.csv`, and read it into a data frame\n",
    "filename = '../data/so_2021_survey_results.csv'\n",
    "df = pd.read_csv(filename, usecols=['LanguageHaveWorkedWith', \n",
    "                                    'LanguageWantToWorkWith',\n",
    "                                    'Country', 'CompTotal'])\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "47320111",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['JavaScript', 'HTML/CSS', 'Python', 'SQL', 'Java', 'Node.js',\n",
       "       'TypeScript', 'C#', 'Bash/Shell', 'C++', 'PHP', 'C', 'PowerShell', 'Go',\n",
       "       'Kotlin', 'Rust', 'Ruby', 'Dart', 'Assembly', 'Swift', 'R', 'VBA',\n",
       "       'Matlab', 'Groovy', 'Objective-C', 'Scala', 'Perl', 'Haskell', 'Delphi',\n",
       "       'Clojure', 'Elixir', 'LISP', 'Julia', 'F#', 'Erlang', 'APL', 'Crystal',\n",
       "       'COBOL'],\n",
       "      dtype='object', name='LanguageHaveWorkedWith')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What are the different programming languages that developers currently use?\n",
    "(\n",
    "    df['LanguageHaveWorkedWith']\n",
    "    .str.split(';')\n",
    "    .explode()\n",
    "    .value_counts()\n",
    "    .index\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a19eb025",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['JavaScript', 'HTML/CSS', 'Python', 'SQL', 'Java', 'Node.js',\n",
       "       'TypeScript', 'C#', 'Bash/Shell', 'C++'],\n",
       "      dtype='object', name='LanguageHaveWorkedWith')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What are the 10 programming languages most commonly used today?\n",
    "have_worked_with = (\n",
    "    df['LanguageHaveWorkedWith']\n",
    "    .str.split(';')\n",
    "    .explode()\n",
    "    .value_counts()\n",
    "    .head(10)\n",
    "    .index\n",
    ")\n",
    "\n",
    "have_worked_with"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "85075a6e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['JavaScript', 'Python', 'HTML/CSS', 'TypeScript', 'SQL', 'Node.js',\n",
       "       'C#', 'Java', 'Rust', 'Go'],\n",
       "      dtype='object', name='LanguageWantToWorkWith')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What are the 10 programming languages people most want to use?\n",
    "want_to_work_with = (\n",
    "    df['LanguageWantToWorkWith']\n",
    "    .str.split(';')\n",
    "    .explode()\n",
    "    .value_counts()\n",
    "    .head(10)\n",
    "    .index\n",
    ")\n",
    "want_to_work_with"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f7a3ba6d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['JavaScript', 'Python', 'HTML/CSS', 'TypeScript', 'SQL', 'Node.js',\n",
       "       'C#', 'Java'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What languages are on both top-10 lists?\n",
    "\n",
    "want_to_work_with.intersection(have_worked_with)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "486619fd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Bash/Shell', 'C++'], dtype='object', name='LanguageHaveWorkedWith')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What languages in the top 10 have people worked with, but *don't* want to work with in the future?\n",
    "(\n",
    "    have_worked_with\n",
    "    [~have_worked_with.isin(want_to_work_with)]\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "846f56ad",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>LanguageHaveWorkedWith</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Country</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Afghanistan</th>\n",
       "      <td>JavaScript</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Albania</th>\n",
       "      <td>JavaScript</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Algeria</th>\n",
       "      <td>JavaScript</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Andorra</th>\n",
       "      <td>JavaScript</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Angola</th>\n",
       "      <td>[HTML/CSS, JavaScript]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Venezuela, Bolivarian Republic of...</th>\n",
       "      <td>JavaScript</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Viet Nam</th>\n",
       "      <td>JavaScript</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Yemen</th>\n",
       "      <td>[C#, HTML/CSS]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Zambia</th>\n",
       "      <td>HTML/CSS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Zimbabwe</th>\n",
       "      <td>JavaScript</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>181 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                      LanguageHaveWorkedWith\n",
       "Country                                                     \n",
       "Afghanistan                                       JavaScript\n",
       "Albania                                           JavaScript\n",
       "Algeria                                           JavaScript\n",
       "Andorra                                           JavaScript\n",
       "Angola                                [HTML/CSS, JavaScript]\n",
       "...                                                      ...\n",
       "Venezuela, Bolivarian Republic of...              JavaScript\n",
       "Viet Nam                                          JavaScript\n",
       "Yemen                                         [C#, HTML/CSS]\n",
       "Zambia                                              HTML/CSS\n",
       "Zimbabwe                                          JavaScript\n",
       "\n",
       "[181 rows x 1 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What is the most popular (current) language used by people in each country?\n",
    "\n",
    "all_languages = (\n",
    "    df\n",
    "    ['LanguageHaveWorkedWith']\n",
    "    .str.split(';')\n",
    "    .explode()\n",
    ")\n",
    "\n",
    "(\n",
    "    df[['Country']]\n",
    "    .join(all_languages)\n",
    "    .groupby('Country')\n",
    "    .agg(pd.Series.mode)\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "b7b95035",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.373678011583714"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What is the mean number of languages used in the last year?\n",
    "df['LanguageHaveWorkedWith'].str.split(';').str.len().mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c769fc1c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38.0"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# What is the greatest number of languages people listed as having used in the last year?\n",
    "df['LanguageHaveWorkedWith'].str.split(';').str.len().max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f21bd529",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# How many people chose that largest number?\n",
    "\n",
    "(\n",
    "    df\n",
    "    .loc[df['LanguageHaveWorkedWith']\n",
    "         .str.split(';')\n",
    "         .str.len() == 38,\n",
    "        'LanguageHaveWorkedWith']\n",
    "    .count()\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "a2dfdd11",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2369"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# How many people in the survey claim salaries of $2m or above?\n",
    "\n",
    "(\n",
    "    df\n",
    "    .loc[df['CompTotal'] >= 2_000_000]\n",
    "    ['CompTotal']\n",
    "    .count()\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "3c85dceb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Remove rows in which salaries are >= $2m\n",
    "df = (\n",
    "    df\n",
    "    .loc[df['CompTotal'] < 2_000_000]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9a49b6c9",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>CompTotal</th>\n",
       "      <th>LanguageHaveWorkedWith</th>\n",
       "      <th>LanguageWantToWorkWith</th>\n",
       "      <th>APL</th>\n",
       "      <th>Assembly</th>\n",
       "      <th>Bash/Shell</th>\n",
       "      <th>C</th>\n",
       "      <th>C#</th>\n",
       "      <th>C++</th>\n",
       "      <th>...</th>\n",
       "      <th>PowerShell</th>\n",
       "      <th>Python</th>\n",
       "      <th>R</th>\n",
       "      <th>Ruby</th>\n",
       "      <th>Rust</th>\n",
       "      <th>SQL</th>\n",
       "      <th>Scala</th>\n",
       "      <th>Swift</th>\n",
       "      <th>TypeScript</th>\n",
       "      <th>VBA</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Slovakia</td>\n",
       "      <td>4800.0</td>\n",
       "      <td>C++;HTML/CSS;JavaScript;Objective-C;PHP;Swift</td>\n",
       "      <td>Swift</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Sweden</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>C++;Python</td>\n",
       "      <td>Haskell;Python</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Spain</td>\n",
       "      <td>43000.0</td>\n",
       "      <td>Bash/Shell;HTML/CSS;JavaScript;Node.js;SQL;Typ...</td>\n",
       "      <td>C++;Clojure;JavaScript;Node.js;Rust;SQL;TypeSc...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Germany</td>\n",
       "      <td>71500.0</td>\n",
       "      <td>C;C++;Java;Perl;Ruby</td>\n",
       "      <td>Rust</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>Turkey</td>\n",
       "      <td>9000.0</td>\n",
       "      <td>C#;HTML/CSS;Java;JavaScript;Node.js</td>\n",
       "      <td>C#;Java;JavaScript;Node.js</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83434</th>\n",
       "      <td>United States of America</td>\n",
       "      <td>160500.0</td>\n",
       "      <td>Clojure;Kotlin;SQL</td>\n",
       "      <td>Clojure</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83435</th>\n",
       "      <td>Benin</td>\n",
       "      <td>200000.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83436</th>\n",
       "      <td>United States of America</td>\n",
       "      <td>1800.0</td>\n",
       "      <td>Groovy;Java;Python</td>\n",
       "      <td>Java;Python</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83437</th>\n",
       "      <td>Canada</td>\n",
       "      <td>90000.0</td>\n",
       "      <td>Bash/Shell;JavaScript;Node.js;Python</td>\n",
       "      <td>Go;Rust</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83438</th>\n",
       "      <td>Brazil</td>\n",
       "      <td>7700.0</td>\n",
       "      <td>Delphi;Elixir;HTML/CSS;Java;JavaScript</td>\n",
       "      <td>Elixir;HTML/CSS;Java;JavaScript;Node.js;PHP;SQ...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>44814 rows × 42 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                        Country  CompTotal  \\\n",
       "0                      Slovakia     4800.0   \n",
       "9                        Sweden    42000.0   \n",
       "11                        Spain    43000.0   \n",
       "12                      Germany    71500.0   \n",
       "16                       Turkey     9000.0   \n",
       "...                         ...        ...   \n",
       "83434  United States of America   160500.0   \n",
       "83435                     Benin   200000.0   \n",
       "83436  United States of America     1800.0   \n",
       "83437                    Canada    90000.0   \n",
       "83438                    Brazil     7700.0   \n",
       "\n",
       "                                  LanguageHaveWorkedWith  \\\n",
       "0          C++;HTML/CSS;JavaScript;Objective-C;PHP;Swift   \n",
       "9                                             C++;Python   \n",
       "11     Bash/Shell;HTML/CSS;JavaScript;Node.js;SQL;Typ...   \n",
       "12                                  C;C++;Java;Perl;Ruby   \n",
       "16                   C#;HTML/CSS;Java;JavaScript;Node.js   \n",
       "...                                                  ...   \n",
       "83434                                 Clojure;Kotlin;SQL   \n",
       "83435                                                NaN   \n",
       "83436                                 Groovy;Java;Python   \n",
       "83437               Bash/Shell;JavaScript;Node.js;Python   \n",
       "83438             Delphi;Elixir;HTML/CSS;Java;JavaScript   \n",
       "\n",
       "                                  LanguageWantToWorkWith  APL  Assembly  \\\n",
       "0                                                  Swift    0         0   \n",
       "9                                         Haskell;Python    0         0   \n",
       "11     C++;Clojure;JavaScript;Node.js;Rust;SQL;TypeSc...    0         0   \n",
       "12                                                  Rust    0         0   \n",
       "16                            C#;Java;JavaScript;Node.js    0         0   \n",
       "...                                                  ...  ...       ...   \n",
       "83434                                            Clojure    0         0   \n",
       "83435                                                NaN    0         0   \n",
       "83436                                        Java;Python    0         0   \n",
       "83437                                            Go;Rust    0         0   \n",
       "83438  Elixir;HTML/CSS;Java;JavaScript;Node.js;PHP;SQ...    0         0   \n",
       "\n",
       "       Bash/Shell  C  C#  C++  ...  PowerShell  Python  R  Ruby  Rust  SQL  \\\n",
       "0               0  0   0    1  ...           0       0  0     0     0    0   \n",
       "9               0  0   0    1  ...           0       1  0     0     0    0   \n",
       "11              1  0   0    0  ...           0       0  0     0     0    1   \n",
       "12              0  1   0    1  ...           0       0  0     1     0    0   \n",
       "16              0  0   1    0  ...           0       0  0     0     0    0   \n",
       "...           ... ..  ..  ...  ...         ...     ... ..   ...   ...  ...   \n",
       "83434           0  0   0    0  ...           0       0  0     0     0    1   \n",
       "83435           0  0   0    0  ...           0       0  0     0     0    0   \n",
       "83436           0  0   0    0  ...           0       1  0     0     0    0   \n",
       "83437           1  0   0    0  ...           0       1  0     0     0    0   \n",
       "83438           0  0   0    0  ...           0       0  0     0     0    0   \n",
       "\n",
       "       Scala  Swift  TypeScript  VBA  \n",
       "0          0      1           0    0  \n",
       "9          0      0           0    0  \n",
       "11         0      0           1    0  \n",
       "12         0      0           0    0  \n",
       "16         0      0           0    0  \n",
       "...      ...    ...         ...  ...  \n",
       "83434      0      0           0    0  \n",
       "83435      0      0           0    0  \n",
       "83436      0      0           0    0  \n",
       "83437      0      0           0    0  \n",
       "83438      0      0           0    0  \n",
       "\n",
       "[44814 rows x 42 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Turn the 'LanguageHaveWorkedWith' column into \"dummy\" columns in df, such that\n",
    "# each language is its own column.\n",
    "\n",
    "df = (\n",
    "    pd.concat([df, \n",
    "               df['LanguageHaveWorkedWith']\n",
    "               .str.get_dummies(sep=';')],\n",
    "              axis='columns')\n",
    ")\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "8ac6ed61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "126817.99470235605"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# If you want to maximize your salary, and have to choose two languages from\n",
    "# Python, JavaScript, and Java, then what combination would be best?\n",
    "\n",
    "# Python + JavaScript, not Java\n",
    "df['CompTotal'][(df['Python'] == 1) &\n",
    "                (df['JavaScript'] == 1) &\n",
    "                (df['Java'] == 0)].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "db3cd8e0",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "162737.10379596677"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Python + Java, not JavaScript\n",
    "df['CompTotal'][(df['Python'] == 1) &\n",
    "                (df['JavaScript'] == 0) &\n",
    "                (df['Java'] == 1)].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5508df7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "140867.65981559738"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Java and Javascript, not Python\n",
    "df['CompTotal'][(df['Python'] == 0) &\n",
    "                (df['JavaScript'] == 1) &\n",
    "                (df['Java'] == 1)].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a1c15898",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
